<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>自定义遍历数据</title>
</head>
<body>
    <script>
        const banji = {
            name:'最牛的0331',
            members:[
                '赵娜娜',
                '李斌虎',
                '胡嘉莉',
                '帅哥',
                '王新田'
            ],
            [Symbol.iterator]:function(){
                let index = 0;
                let done = false;
                return {
                    next:()=>{
                        // index++;
                        // if(index > 5){
                        //     done = true;
                        // }
                        // return {value:index,done:done}
                        // { value:'赵娜娜',done:false}
                        // { value:'李斌虎',done:false}
                        // { value:'胡嘉莉',done:false}
                        // { value:'帅哥',done:false}
                        // { value:'王新田',done:false}
                        // { value:undefined,done:true}
                        let value = this.members[index];
                        done = index >= this.members.length;
                        index++;
                        return {value,done}
                    }
                }
            }
        }

        for(let v of banji){
            console.log(v);//赵娜娜 李斌虎
        }

        let iterator = banji[Symbol.iterator]();

        console.log(iterator.next());
        console.log(iterator.next());
        console.log(iterator.next());
        console.log(iterator.next());
        console.log(iterator.next());
        console.log(iterator.next());

    </script>
</body>

</html>